﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>创建随机数</title>
</head>
<body>
<script language="JavaScript">
    rnd.today = new Date();
    rnd.seed = rnd.today.getTime();
    function rnd(){
        rnd.seed = (rnd.seed * 9301 + 49297) % 233280;
        return rnd.seed / (233280.0);
    };
    function rand(number){
        return Math.ceil(rnd() * number);
    }
</script>
<input type=button name="btn1" value="获取整数随机数" onClick="alert(rand(20))">
<input type=button value="获取浮点数随机数" onClick="alert(rnd())">
</body>
</html>